package com.lwc.cfdns.pojo.bo.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lwc.cfdns.pojo.bo.AbstractPageQuery;
import com.lwc.cfdns.pojo.entity.SystemMenu;
import com.lwc.cfdns.utils.ConvertUtils;
import com.lwc.cfdns.utils.StringUtils;
import lombok.Data;

/**
 * 菜单
 *
 * @author luwc
 * @title MenuBO
 * @description
 * @time 2023/5/23 17:11:54
 * @version: 1.0
 */
@Data
public class MenuBO extends AbstractPageQuery {
    private Integer status;
    private String name;
    private Integer visible;

    /**
     * 生成query conditions
     *
     * @return LambdaQueryWrapper<T>
     * @throws
     * @version 1.0.0
     * @author luwc
     * @time 2023/4/26 20:17:17
     */
    @Override
    public LambdaQueryWrapper<SystemMenu> toQueryWrapper() {
        LambdaQueryWrapper<SystemMenu> lambdaQueryWrapper = new LambdaQueryWrapper<>();

        if (StringUtils.isNotEmpty(ConvertUtils.toStr(this.status))) {
            lambdaQueryWrapper.eq(SystemMenu::getStatus, this.status);
        }
        if (StringUtils.isNotEmpty(this.name)) {
            lambdaQueryWrapper.like(SystemMenu::getName, this.name);
        }
        if (StringUtils.isNotEmpty(ConvertUtils.toStr(this.visible))) {
            lambdaQueryWrapper.eq(SystemMenu::getVisible, this.visible);
        }
        lambdaQueryWrapper.orderByAsc(SystemMenu::getSort);
        return lambdaQueryWrapper;
    }
}
